<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>组件Prop类型</title>
    <script src="../vue.global.js"></script>
    <style>
        .red{
            color:red;
        }
        .font-big{
            font-size: 50px;
        }
    </style>
</head>
<body>

<div id="App">

    <!--<html-a parent-msg="33"></html-a>  静态方式props  适合传递字符串 -->
    <!--<html-a :parent-msg="33"></html-a>-->
    <!--<html-a :parent-msg="posts.likes"></html-a>-->
    <!--<html-a :parent-msg="{name:'xxxbb'}"></html-a>-->
    <!--<html-a :parent-msg="posts"></html-a>-->
    <html-a v-bind="posts"></html-a> 结果就是: <div likes="888" id="999" city="上海">子组件hello</div>

</div>


<script>


    const htmlA = {//子组件
        data(){  //数据
            return {
                message:"子组件hello"
            }
        },
       // props:['abc'],//组件通信
        //props:['parentMsg'],//组件通信
        // props:{
        //   parentMsg:Number,//限制数据类型
        // },
        props:{
            parentMsg:Object,//限制数据类型
        },
        //模板
       // template:`<!--<div>{{message}}</div><div>{{typeof parentMsg}}</div>-->`
        //template:`<div>{{message}}</div><div>{{parentMsg.name}}</div>`
        //template:`<div>{{message}}</div><div>{{parentMsg}}</div>`
        template:`<div>{{message}}</div>`
    };

    const vm = Vue.createApp({  //根组件

        data(){
            return {
                message:"父组件hello",
                posts:{
                    likes:888,
                    id:999,
                    city:"上海"
                }
            }
        },
        components:{
            'html-a':htmlA
        }
    });
    vm.mount("#App");


</script>
</body>
</html>